 package net.go176.backpack.util;
 
 import java.io.File;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.UUID;
 import net.go176.backpack.core.DataType;
 import org.bukkit.Bukkit;
 import org.bukkit.Server;
 import org.bukkit.entity.Player;
 
 
 
 public class DataUtil
 {
   public static File getMybDataFolder() {
     return new File("plugins/Backpack/playerdata");
   }
   
   public static File getDataFolder() {
     return new File("world/playerdata");
   }
   
   public static File getDataFolderOld() {
     return new File("world/players");
   }
   
   private static Method onlinePlayers = null;
   private static boolean legacy = false;
   
   static {
     try {
       onlinePlayers = Server.class.getMethod("getOnlinePlayers", new Class[0]);
       legacy = onlinePlayers.getReturnType().equals(Player[].class);
     } catch (Exception e) {
       e.printStackTrace();
     } 
   }
   
   public static Collection<Player> getOnlinePlayers() {
     try {
       return legacy ? Arrays.<Player>asList((Player[])onlinePlayers.invoke(Bukkit.getServer(), new Object[0])) : (Collection<Player>)onlinePlayers.invoke(Bukkit.getServer(), new Object[0]);
     } catch (Exception e) {
       return null;
     } 
   }
   
   public static UUID getOfflinePlayerUUID(String playerName) {
     return Bukkit.getOfflinePlayer(playerName).getUniqueId();
   }
   
   public static File getMybDataFile(DataType type, String link, String playerName, boolean mkdirs) {
     File folder = new File(getMybDataFolder() + "/" + link, type.folderName);
     if (mkdirs && (!folder.exists() || !folder.isDirectory()))
       folder.mkdirs(); 
     return new File(folder, String.valueOf(playerName) + type.extension);
   }
 }


/* Location:              D:\User\Xuan\Downloads\MyBackpack1.2.5.jar!\net\saralab\mybackpac\\util\DataUtil.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.1.3
 */